import request from '../utils/request'

export const getUserChannelsApi = function () {
  return request.get('/v1_0/user/channels')
}

// 根据频道ID和时间戳请求文章列表数据的api
// id是频道的id
// time是时间戳(首页的值是Date.now(),其他页面的值是上次请求拿到的是pre_timestamp的值)
export const getArtListAPI = function (id, time) {
  return request.get('/v1_0/articles', {
    params: {
      channel_id: id,
      timestamp: time
    }
  })
}
// 将文章设置为不感兴趣
export const dislikeArticleAPI = function (id) {
  return request.post('/v1_0/article/dislikes', { target: id })
}

// 举报文章的api
// target举报文章的id
// type举报文章的类型
export const reportArticleAPI = function (target, type) {
  return request.post('/v1_0/article/reports', { target, type })
}
export const getAllChannelAPI = () => {
  return request.get('/v1_0/channels')
}

// 更新用户的频道
// channels为数组,数组中的格式为 id,seq
export const updateUserChannelAPI = (channels) => {
  return request.put('/v1_0/user/channels', { channels })
}
